export function viewReport (reportName, params) {
  // 拿到环境变量中的VITE_ADMIN_PROXY_IP
  // 获取当前环境
  // const href = import.meta.env.VITE_ADMIN_PROXY_IP + '/ureport/preview?'
  const environment = process.env.NODE_ENV
  let href
  if (environment === 'production') {
    href = 'http://172.16.100.10:9770/report/ureport/preview?'
  } else {
    href = 'http://172.16.100.10:9770/report/ureport/preview?'
  }
  // const href = 'http://172.16.100.10:9770/report/ureport/preview?'
  // let href = 'http://localhost:18081/ureport/preview?';
  const filterArr = []
  // btns = btns && btns.length > 1 ? btns : [1, 2, 3, 4, 5, 6, 7, 8, 9]
  // filterArr.push("_t=" + btns.join(','));
  filterArr.push('_u=mysql-' + reportName + '.ureport.xml')
  filterArr.push('n=' + reportName)
  for (const key in params) {
    filterArr.push(params[key] ? (key + '=' + params[key]) : '')
  }

  window.open(href + filterArr.join('&'), '_blank')
}

export function testViewReportUrl () {
  console.log(import.meta.env.VITE_ADMIN_PROXY_IP + ':18081/ureport/preview')
}
